<template>
	<view class="me-box">
		<TopBar :indexflag="true" :combakflag="false" :lang="false" :bottom="true" :title="$t('Me')"
			barstyle="background-color:rgba(0,0,0,0)"></TopBar>
		<view class="me-header">
			<view class="user-box">
				<view class="avartar">
					<image src="../../static/images/logo.jpg" mode=""></image>
				</view>
				<view class="username">hero</view>
			</view>
		</view>
		<view class="menu-box">
			<view class="top-menu">
				<view class="item" v-for="(item,index) in top_menu" @click="changemenu(item.url)">
					<u-icon :name="item.icon" color="#45BC1B" size="26"></u-icon>
					<text class="item-title">{{$t(item.name)}}</text>
				</view>
			</view>
			<view class="footer-menu">
				<view class="item" v-for="(item,index) in footer_menu" @click="changemenu(item.url,index)">
					<view class="title">
						<u-icon :name="item.icon" color="#45BC1B" size="26"></u-icon>
						<text>{{$t(item.name)}}</text>
					</view>
					<view class="icon-box">
						<u-icon name="arrow-right" color="#fff" size="16"></u-icon>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import TopBar from "@/components/TopBar.vue"
	import HeaderTitle from "@/components/HeaderTitle.vue"
	var jweixin = require('jweixin-module');
	import jwx from '@/utils/jwx.js'
	import alert from "../../uni_modules/uview-ui/libs/config/props/alert";
	export default {
		components: {
			TopBar,
			HeaderTitle
		},
		data() {
			return {
				top_menu: [{
						name: 'DeliveryAddress',
						icon: 'map',
						url: '/pages/me/address/address'
					},
					{
						name: 'PersonalInformation',
						icon: 'account',
						url: ''
					},
					{
						name: 'Integral',
						icon: 'integral',
						url: ''
					}
				],
				footer_menu: [
					// {
					// 	name: 'MyComment',
					// 	icon: 'chat',
					// 	url: ''
					// },
					{
						name: 'Share',
						icon: 'share',
						url: ''
					},
					{
						name: 'DeliveryPerson',
						icon: 'man-add',
						url: '/pages/me/deliveryperson'
					},
					{
						name: 'JoinAlliance',
						icon: 'bookmark',
						url: '/pages/me/joinalliance'
					},
					{
						name: 'LocalService',
						icon: 'kefu-ermai',
						url: ''
					},
					// {
					// 	name: '在线客服',
					// 	icon: 'server-man',
					// 	url: ''
					// },
					{
						name: 'Headquarters',
						icon: 'phone',
						url: ''
					},
					{
						name: 'AboutUs',
						icon: 'error-circle',
						url: ''
					}
				]
			}
		},
		onShow() {
			uni.hideTabBar({
				animation: false
			})

		},
		mounted() {
			// this.translationAlign('zh','深圳城','uy');
		},
		methods: {
			changemenu(url, index) {
				if (url) {
					uni.navigateTo({
						url: url
					})
				} else {
					if (index == 0) {

						jwx.initJssdk();
						jweixin.ready(() => {
							 jweixin.updateAppMessageShareData({ 
							    title: '23', // 分享标题
							    desc: '23', // 分享描述
							    link: window.location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
							    imgUrl: 'http://icon.mobanwang.com/UploadFiles_8971/200910/20091011134333685.png', // 分享图标
							    success: function () {
							      // 设置成功
							    }
							  })
							jweixin.onMenuShareTimeline({
								title: '测试分享', // 分享标题
								link: window.location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
								imgUrl: 'http://icon.mobanwang.com/UploadFiles_8971/200910/20091011134333685.png', // 分享图标
								success: function() {
									// 用户点击了分享后执行的回调函数
								}
							});
							jweixin.onMenuShareAppMessage({
								title: '测试分享', // 分享标题
								desc: '一个测试的分享!!!', // 分享描述
								link: window.location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
								imgUrl: 'http://icon.mobanwang.com/UploadFiles_8971/200910/20091011134333685.png', // 分享图标
								type: "", // 分享类型,music、video或link，不填默认为link
								dataUrl: "", // 如果type是music或video，则要提供数据链接，默认为空
								success: function() {
									// 用户点击了分享后执行的回调函数
								}
							})
						})
					} else if (index == 3 ) {
						this.changeMobile('17690927591')
					}else if (index == 4) {
						this.changeMobile('17690927591')
					} else if (index == 5) {
						this.changeMobile('17690892378')
					} else {
						if (this.$i18n.locale == 'cn') {
							uni.showToast({
								title: '待开发 !',
								icon: "none",
								duration: 3000,

							})
						} else {
							uni.showToast({
								title: 'ياسىلۋاتىدۇ',
								icon: "none",
								duration: 3000,

							})
						}

					}

				}


			},
			changeMobile(mobile) {
				uni.makePhoneCall({
					phoneNumber: mobile
				})

			}

		}
	}
</script>

<style lang="scss" scoped>
	.me-box {
		width: 100%;
		height: 100%;
		padding-bottom: 300rpx;

		.me-header {
			width: 100%;
			height: 330rpx;
			background: url('../../static/images/me_bg.png');
			background-repeat: no-repeat;
			background-size: 100% 100%;
			background-color: #15c45b;
			display: flex;
			justify-content: center;
			// align-items: center;
			border-radius: 0rpx 0rpx 15rpx 15rpx;

			.user-box {
				display: flex;
				flex-direction: column;
				align-items: center;
				margin-top: 30rpx;

				.avartar {
					width: 120rpx;
					height: 120rpx;
					border-radius: 100%;
					background-color: rgba(0, 0, 0, 0.2);

					image {
						width: 100%;
						height: 100%;
						border-radius: 100%;
					}
				}

				.username {
					color: #fff;
					font-size: $uni-font-size-lg;
					margin-top: $uni-spacing-margin-sm;
				}
			}
		}

		.menu-box {
			width: 100%;
			padding: 0rpx 30rpx;
			margin-top: -70rpx;
			box-sizing: border-box;

			.top-menu {
				width: 100%;
				display: flex;
				justify-content: space-around;
				align-items: center;
				background-color: #fff;
				border-radius: $uni-border-radius-lg;
				padding: 40rpx $uni-spacing-padding-sm;
				box-sizing: border-box;
				color: $uni-color-title;
				font-size: $uni-font-size-sm1 ;
				box-shadow: $uni-bg-shadow;
				font-weight: 500;

				.item {
					display: flex;
					flex-direction: column;
					align-items: center;

					.icon {}

					.item-title {
						padding-top: 10rpx;
						padding-bottom: 10rpx;
					}
				}
			}

			.footer-menu {
				width: 100%;
				box-sizing: border-box;
				margin-top: 30rpx;

				.item {
					display: flex;
					justify-content: space-between;
					align-items: center;
					box-sizing: border-box;
					padding: 30rpx 20rpx;
					// border-bottom: 1rpx solid $uni-border-color;
					color: $uni-color-title;
					font-size: $uni-font-size-sm1 ;
					border-radius: $uni-border-radius-lg;
					margin-top: $uni-spacing-margin-sm;
					background-color: $uni-text-color-inverse;
					box-shadow: $uni-bg-shadow;
					font-weight: 500;

					.title {
						display: flex;
						align-items: center;

						text {
							padding: 0rpx 20rpx;

						}
					}

					.icon-box {
						padding: 15rpx;
						background-color: $uni-color-topic;
						box-shadow: $uni-bg-shadow;
						border-radius: $uni-border-radius-base;

					}
				}
			}
		}
	}
</style>